package com.wangsd.common.component.extBean;

import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.Data;
import me.chanjar.weixin.common.util.xml.XStreamInitializer;

@XStreamAlias("xml")
@Data
public class AuthinfoResponse extends BaseWxPayResult {

    //SDK调用凭证。用于调用SDK的人脸识别接口
    @XStreamAlias("authinfo")
    private String authinfo;

    //authinfo的有效时间, 单位秒
    @XStreamAlias("expires_in")
    private int expires_in;

    private String storeId;

    public static AuthinfoResponse fromXML(String xmlString) {
        XStream xstream = XStreamInitializer.getInstance();
        xstream.allowTypesByWildcard(new String[]{"me.chanjar.weixin.**",
                "cn.binarywang.wx.**", "com.github.binarywang.**",
                "com.wangsd.common.component.**"});
        xstream.processAnnotations(AuthinfoResponse.class);
        AuthinfoResponse result = (AuthinfoResponse) xstream.fromXML(xmlString);
        result.setXmlString(xmlString);
        return result;
    }
}
